home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir24 / jnos110g.zip / DEVPARAM.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  2KB  |  75 lines

  1. #include <ctype.h>
  2. #include "global.h"
  3. #include "devparam.h"
  4.   
  5. struct param {
  6.     int number;
  7.     char *name;
  8. };
  9. static struct param Parms[] = {
  10.     PARAM_DATA, "Data",
  11.     PARAM_TXDELAY,  "TxDelay",
  12.     PARAM_PERSIST,  "Persist",
  13.     PARAM_SLOTTIME, "SlotTime",
  14.     PARAM_TXTAIL,   "TxTail",
  15.     PARAM_FULLDUP,  "FullDup",
  16.     PARAM_HW,   "Hardware",
  17.     PARAM_MUTE, "TxMute",
  18.     PARAM_DTR,  "DTR",
  19.     PARAM_RTS,  "RTS",
  20.     PARAM_SPEED,    "Speed",
  21.     PARAM_ENDDELAY, "EndDelay",
  22.     PARAM_GROUP,    "Group",
  23.     PARAM_IDLE, "Idle",
  24.     PARAM_MIN,  "Min",
  25.     PARAM_MAXKEY,   "MaxKey",
  26.     PARAM_WAIT, "Wait",
  27.     PARAM_DOWN, "Down",
  28.     PARAM_UP,   "Up",
  29.     PARAM_BLIND,    "Blind",
  30.     PARAM_RCV_MODE, "RcvMode", /* packet driver receive mode - WG7J */
  31.     PARAM_RETURN,   "Return",
  32.     PARAM_RETURN2,  "Return2",
  33.     -1,     NULLCHAR,
  34. };
  35.   
  36. /* Convert a packet radio interface control token into a number
  37.  * Used by the various ioctl routines and by KISS TNC commands
  38.  */
  39. int
  40. devparam(s)
  41. char *s;
  42. {
  43.     int len;
  44.     struct param *sp;
  45.   
  46.     len = strlen(s);
  47.     if(isdigit(s[0]))
  48.         return atoi(s);
  49.   
  50.     sp = &Parms[0];
  51.     while(sp->number != -1){
  52.         if(strnicmp(s,sp->name,len) == 0)
  53.             return sp->number;
  54.         sp++;
  55.     }
  56.     return -1;
  57. }
  58.   
  59. char *
  60. parmname(n)
  61. int n;
  62. {
  63.     struct param *sp;
  64.   
  65.     sp = &Parms[0];
  66.     while(sp->number != -1){
  67.         if(sp->number == n)
  68.             return sp->name;
  69.         sp++;
  70.     }
  71.     return NULLCHAR;
  72. }
  73.   
  74.   
  75.